#include <iostream>
//#include <string>

using namespace std;

int main()
{
    int n;
	for(cin>>n;n>0;n--)
    {
		int base,days;
		double e_rate,f_rate,g_rate;
		double case1,case2;
		cin>>base>>days>>e_rate>>f_rate>>g_rate;
		case1=(base*(1+e_rate/100*days/365))*(1+g_rate/100);
		case2=base*(1+f_rate/100*(days+365)/365);
		cout<<case1<<endl;
		cout<<case2<<endl;
    }
	//system("PAUSE");
	return 0;
}
